/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package stis.statpro.ibs.dao;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import stis.statpro.ibs.datasource.Datasource;
import stis.statpro.ibs.datasource.QueryClass;

/**
 *
 * @author habib <imamhabibpamungkas@gmail.com>
 */
public class ResumeDao implements ResumeDaoInface{

    @Override
    public int getJumlahRecord() throws SQLException {
        PreparedStatement statement = Datasource.getConnection().prepareStatement(QueryClass.GETJUMLAHRECORD);
        ResultSet rs = statement.executeQuery();
        int i=0;
        while(rs.next()){
            i= rs.getInt(1);
        }
        statement.close();
        return i;
    }

    @Override
    public int getJumlahTenagaKerja() throws SQLException {
        PreparedStatement statement = Datasource.getConnection().prepareStatement(QueryClass.GETSUMTENAGA);
        ResultSet rs = statement.executeQuery();
        int i=0;
        while(rs.next()){
            i= rs.getInt(1);
        }
        statement.close();
        return i;
    }

    @Override
    public double getRataOmset() throws SQLException {
        PreparedStatement statement = Datasource.getConnection().prepareStatement(QueryClass.GETAVERAGE);
        ResultSet rs = statement.executeQuery();
        int i=0;
        while(rs.next()){
            i= rs.getInt(1);
        }
        statement.close();
        return i;
    }

    @Override
    public int getModalPmdn() throws SQLException {
        PreparedStatement statement = Datasource.getConnection().prepareStatement(QueryClass.GETCOUNTSTATUSMODAL);
        statement.setString(1, "%pmdn%");
        ResultSet rs = statement.executeQuery();
        int i=0;
        while(rs.next()){
            i= rs.getInt(1);
        }
        statement.close();
        return i;
    }

    @Override
    public int getModalPma() throws SQLException {
        PreparedStatement statement = Datasource.getConnection().prepareStatement(QueryClass.GETCOUNTSTATUSMODAL);
        statement.setString(1, "%pma%");
        ResultSet rs = statement.executeQuery();
        int i=0;
        while(rs.next()){
            i= rs.getInt(1);
        }
        statement.close();
        return i;
    }

    @Override
    public int getModalNon() throws SQLException {
        PreparedStatement statement = Datasource.getConnection().prepareStatement(QueryClass.GETCOUNTSTATUSMODAL);
        statement.setString(1, "%non%");
        ResultSet rs = statement.executeQuery();
        int i=0;
        while(rs.next()){
            i= rs.getInt(1);
        }
        statement.close();
        return i;
    }

    @Override
    public int getDlmIndustri() throws SQLException {
        PreparedStatement statement = Datasource.getConnection().prepareStatement(QueryClass.GETLOKASI);
        statement.setString(1, "%dalam%");
        ResultSet rs = statement.executeQuery();
        int i=0;
        while(rs.next()){
            i= rs.getInt(1);
        }
        statement.close();
        return i;
    }

    @Override
    public int getLuarIndustri() throws SQLException {
        PreparedStatement statement = Datasource.getConnection().prepareStatement(QueryClass.GETLOKASI);
        statement.setString(1, "%luar%");
        ResultSet rs = statement.executeQuery();
        int i=0;
        while(rs.next()){
            i= rs.getInt(1);
        }
        statement.close();
        return i;
    }
    
}
